import React, { Component } from 'react'
import routers from "./routers"
import {Switch,Route,Redirect} from 'react-router-dom'

export default class RouterMaker extends Component {
    render() {
        return <Switch>
            {routers.map((item,index)=>{
                if(item.component){
                    return <Route key={index} path={item.path} component={item.component} exact={item.exact} /> 
                }else{
                    return <Route key={index} path={item.path} exact={item.exact}>
                        <Redirect to={item.redirect} />
                    </Route> 
                }
            })}
        </Switch>
    }
}
